package com.project.controller;

import com.project.entity.qo.ReceiptMenuRelationQo;
import com.project.entity.qo.ReceiptQo;
import com.project.entity.qo.SelectReceiptListQo;
import com.project.result.ResponseResult;
import com.project.service.ReceiptService;
import com.project.entity.vo.ReceiptVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author qjj
 * @create 2022/3/28 21:29
 */
@RestController
@RequestMapping("/receipt")
public class ReceiptController {
    @Resource
    private ReceiptService receiptService;

    /**
     * 添加发票并返回发票信息
     * @param receiptQo
     * @return
     */
    @PostMapping("/add")
    public ResponseResult<List<ReceiptVo>> addReceipt(@RequestBody ReceiptQo receiptQo){
        return receiptService.addReceipt(receiptQo);
    }

    /**
     * 查看个人所有发票
     * @return
     */
    @GetMapping("/receip/tlist")
    public ResponseResult<List<ReceiptVo>> selectReceiptList(SelectReceiptListQo user){
        return receiptService.selectReceiptList(user);
    }

    /**
     * 加菜
     * @param receiptMenuRelationQos
     * @return
     */
    @PostMapping("/add/menu")
    public ResponseResult<String> addMenu(@RequestBody List<ReceiptMenuRelationQo> receiptMenuRelationQos){
        return receiptService.addMenu(receiptMenuRelationQos);
    }

    /**
     * 删菜
     * @param id
     * @return
     */
    @DeleteMapping("/delete/menu")
    public ResponseResult<String> deleteMenu(@RequestParam("id") @RequestBody List<Long> id){
        return receiptService.deleteRmr(id);
    }

    /**
     * 修改菜
     * @param receiptMenuRelationQo1
     * @return
     */
    @PutMapping("/update/menu")
    public ResponseResult<String> updateMenu(@RequestBody List<ReceiptMenuRelationQo> receiptMenuRelationQo1){
        return receiptService.updateMenu(receiptMenuRelationQo1);
    }
}
